package de.koller.occultation.engine.worldGen;

import de.koller.oceanFramework.gl.util.ImagePreview;
import java.awt.image.BufferedImage;

public class TileGenMapPreview {

	private final TileGenMap map;
	
	public static BufferedImage show( TileGenMap map ) {
		TileGenMapPreview tgmp = new TileGenMapPreview( map );
		return tgmp.diplay();
	}

	private TileGenMapPreview( TileGenMap map ) {
		this.map = map;
	}
	
	private BufferedImage diplay() {
		BufferedImage bi = new BufferedImage( map.getWidth(), map.getHeight(), BufferedImage.TYPE_INT_RGB );
		
		for( int x = 0; x < map.getWidth(); x++ )
			for( int y = 0; y < map.getHeight(); y++ )
				bi.setRGB( x, y, getTileColor( x, y ) );
		
		System.out.println( "show preview" );
		ImagePreview.showImage( bi, map.getWidth(), map.getHeight() );
		return bi;
	}

	private int getTileColor( int x, int y ) {
		int bc = getBaseLayerColor( x, y );
		return bc;
	}

	private int getBaseLayerColor( int x, int y ) {
		TileGenMap.BaseLayer bl = map.getBaseLayer( x, y );
		switch( bl ) {
			case WaterDeep:		return 0xff_0000ff;
			case WaterLow:		return 0xff_14beff;
			case Sand:			return 0xff_ffff00;
			case Grass:			return 0xff_00ff00;
			default: return 0xff_000000;
		}
	}
	
}
